*Replication Do-File #1: Figures 2, 4, 5, 6, 7
*Sigman, Rachel, "Which Jobs for Which Boys? Party Finance and the Politics of State Job Distribution in Africa"
*Comparative Political Studies
*Conditional Acceptance: April 9, 2021

***THIS DO-FILE INCLUDES CODE TO RUN ALL SURVEY-BASED ANALYSIS IN SECTIONS 4 AND 6***

log using "WJWB_SurveyAnalysis_Log.smcl", replace

use "Sigman_2014Survey_replication.dta", clear

*************************************************************
***FIGURE 2: Comparing Resource Diversion Across Countries***
*************************************************************

***Response distributions across countries***
tab diversion country, col
*1=Benin, 2=Ghana

***Horizontal bar graphs comparing countries***
catplot diversion if country ==1, percent stack asyvars legend(off) title("Benin")
graph save cp_div_ben, replace
catplot diversion if country==2, percent stack asyvars legend(off) title("Ghana")
graph save cp_div_gha, replace
graph combine cp_div_ben.gph cp_div_gha.gph, commonscheme rows(2)
*NOTE: Graph editor used to format graph
graph save "diversion_comparison.gph", replace

***Difference-of-means test comparing country averages on this question***
ttest diversion, by(country)
*t=25.41

*********************************************************************
***FIGURE 4: Comparing Public Service Recruitment Across Countries***
*********************************************************************

***Response distributions by country***
tab recruit_self country, col
tab recruit_oth country, col

***Horizontal bar graphs comparing countries***

*How respondent was hired
catplot recruit_self if country == 1, percent stack asyvars legend(off) title("Benin")
graph save recruit1_ben, replace
catplot recruit_self if country == 2, percent stack asyvars legend(off) title("Ghana")
graph save recruit1_gha, replace
graph combine recruit1_ben.gph recruit1_gha.gph, commonscheme rows(2)
*NOTE: Graph editor used to format graph
graph save "recruitself_comparison", replace

*How others in organization were hired
catplot recruit_oth if country == 1, percent stack asyvars legend(off) title("Benin")
graph save recruit2_ben, replace
catplot recruit_oth if country == 2, percent stack asyvars legend(off) title("Ghana")
graph save recruit2_gha, replace
graph combine recruit2_ben.gph recruit2_gha.gph, commonscheme rows(2)
*NOTE: Graph editor used to format graph
graph save "recruit_others", replace

**Difference of proportions test comparing proportions hired politically
prtest polrecruit_self, by(country)
*z=9.87
prtest polrecruit_oth, by(country)
*z=5.96

*********************************************************
***FIGURE 5: Public Service Hiring Regressions (Benin)***
*********************************************************

*Descriptive Statistics (Supplementary Material Table X)
tabstat polhiring_prob pol_firing diversion leaderchange strikes ed_level female years polrecruit_self partymember if country == 1, stat(mean sd min max N) col(stat)
tab orgtype if country == 1

*OLS Regressions
reg polhiring_prob diversion if country ==1, cluster(orgtype)
est sto mod1 
reg polhiring_prob diversion pol_interference leaderchange strikes ed_level female years polrecruit_self partymember i.orgtype if country == 1, cluster(orgtype)
est sto mod2

*Ordered Logit Regressions
ologit polhiring_prob diversion if country==1, cluster(orgtype)
est sto mod3
ologit polhiring_prob diversion pol_interference leaderchange strikes ed_level female years polrecruit_self partymember i.orgtype if country == 1, cluster(orgtype)
est sto mod4

*Coefficient plot for paper (Figure 5)
coefplot mod2, keep(diversion leaderchange ed_level years polrecruit_self partymember) ///
xline(0) levels(90)  xtitle({Estimated Effect on Politicized Hiring (1-4 Scale}), size(small)) ///
graphregion(color(white)) grid(between glcolor(white)) legend(off) ylab(, labs(2.5)) xlab(-1(.2)1, labs(2.5))
*NOTE: Graph editor used to format graph
graph save "coefplot_polhiring", replace

*Complete Results (Table X in Supplementary Material)
esttab mod1 mod2 mod3 mod4, r2 b(3) ///
label star(* 0.10 ** 0.05 *** 0.01)

***************************************************************
***FIGURE 6: Comparing Political Dismissals Across Countries***
***************************************************************

***Response distributions by country***
tab pol_firing country, col

***Horizontal bar graphs comparing countries***
catplot pol_firing if country == 1, percent stack asyvars legend(off) title(Benin)
graph save firing_ben, replace
catplot pol_firing if country == 2, percent stack asyvars legend(off) title(Ghana)
graph save firing_gha, replace
graph combine firing_ben.gph firing_gha.gph, commonscheme rows(2)
*NOTE: Graph editor used to format graph
graph save "poldismissal_comparison", replace

*Difference of means test comparing average response across countries
ttest pol_firing, by(country)
*t=20.34

********************************************************
***FIGURE 7: Political Dismissals Regressions (Benin)***
********************************************************

*OLS Regressions
reg pol_firing diversion if country ==1, cluster(orgtype)
est sto mod5
reg pol_firing diversion pol_interference leaderchange strikes ed_level female years polrecruit_self partymember i.orgtype if country == 1, cluster(orgtype)
est sto mod6

*Ordered logit regressions
ologit pol_firing diversion if country==1, cluster(orgtype)
est sto mod7
ologit pol_firing diversion pol_interference leaderchange strikes ed_level female years polrecruit_self partymember i.orgtype if country == 1, cluster(orgtype)
est sto mod8

*Coefficient plot for paper (Figure 7)
coefplot mod6, keep(diversion leaderchange ed_level years polrecruit_self partymember) xline(0)  ///
levels(90)  xtitle({Estimated Effect on Politicized Dismissal (1-4 Scale}), size(small)) ///
graphregion(color(white)) grid(between glcolor(white)) legend(off) ylab(, labs(2.5)) xlab(-1(.2)1, labs(2.5))
*NOTE: Graph editor used to format graph
graph save "coefplot_poldismissal", replace

*Table for supplementary material
esttab mod5 mod6 mod7 mod8, r2 b(3) ///
label star(* 0.10 ** 0.05 *** 0.01)

log close
